//-----------------------------------------------------------------------------
//
// @file	Color.h
// @brief	Color include files, variables and classes
// @author	Vinod Melapudi
// @date	20Feb2010
//
//-----------------------------------------------------------------------------

#ifndef _COLOR_H
#define _COLOR_H

#include "assert.h"


template<class T>
class Color
{
public:
	union
	{
		struct  
		{
			T	r, g, b, a;
		};
		T		c[4];
	};
	
	Color()	{ r = g = b = a = 0; }

	Color( T _r, T _g, T _b, T _a ):	r(_r),g(_g),b(_b),a(_a)		{}

	void Set( T _r, T _g, T _b, T _a )
	{
		r = _r;	
		g = _g;	
		b = _b;	
		a = _a;
	}

	T  operator[]( int i ) const				{	return c[i];	}

	Color operator+( const Color& opr )	
	{	
		Color out;
		for( int i=0; i < 4; i++ ) 
			out.c[i] = c[i] + opr.c[i];
		return (*this);
	}

	Color operator-( const Color& opr )	
	{	
		Color out;
		for( int i=0; i < 4; i++ ) 
			out.c[i] = c[i] - opr.c[i];
		return (*this);
	}

	Color operator*( float scale )				
	{	
		Color out;
		for( int i=0; i < 4; i++ ) 
			out.c[i] = c[i] * scale;
		return (*this);
	}

	friend Color operator*( float scale, const Color& toScale )
	{	
		Color scaled = toScale;
		for( int i=0; i < 4; i++ ) 
			scaled.c[i] *= scale;
		return scaled;
	}
};


#endif
